﻿using SmartCity.Shared;

namespace CommonManagement
{
    /// <summary>
    /// 登录结果类
    /// </summary>
    public class LoginResponse : ActionResponse<LoginResponse>
    {
        /// <summary>票据</summary>
        public string Token { get; set; }

        /// <summary>
        /// 未找到
        /// </summary>
        /// <param name="userName"></param>
        public static LoginResponse NotFound(string userName)
        {
            return Failed(ResponseCode.未找到资源, $"用户名 {userName} 未注册！");
        }

        /// <summary>
        /// 不匹配
        /// </summary>
        public static LoginResponse Mismatch()
        {
            return Failed(ResponseCode.未找到资源, "用户名或密码错误！");
        }

        /// <summary>
        /// 成功
        /// </summary>
        /// <param name="token"></param>
        public static LoginResponse Successful(string token)
        {
            var result = Successful();
            result.Token = token;
            return result;
        }
    }
}